package com.itheima.goods.controller.user;


import com.itheima.goods.pojo.Setmeal;
import com.itheima.goods.service.SetmealService;
import com.itheima.goods.vo.DishItemVO;
import com.itheima.result.Result;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController("userSetmealController")
@RequestMapping("/user/setmeal")
@Api(tags = "C端-套餐浏览接口")
@Slf4j
public class SetmealController {

    @Autowired
    private SetmealService setmealService;
    @GetMapping("/list")
    public Result list(Long categoryId){
        List<Setmeal> list=setmealService.list(categoryId);
        return Result.success(list);
    }

    /**
     * 根据套餐id查询包含的菜品
     * @param id
     * @return
     */
    @GetMapping("/dish/{id}")
    public Result findById(@PathVariable Long id){
        List<DishItemVO> dishItemVO=setmealService.selectById(id);
        return Result.success(dishItemVO);
    }

}
